<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title> DOM </title>
</head>

<body>
    <a href="" id="tag1">百度</a>
    <span>张三</span>
    <span class="s1">李四</span>
    <span class="s1">王五</span>
    <div >
        盒子
    </div>

</body>
<script>
    let h1 = document.querySelector('h1');

    console.log(  h1.innerHTML  );
    console.log(  h1.innerText  );


    h1.innerHTML = "你好" ;
    
    






    //获取元素
    let tagA = document.getElementById('tag1');
    console.log(tagA);
    

//getElementsByTagName  getElementsByClassName用的较少
    let spans = document.getElementsByTagName('span');
    console.log(spans);
    console.log([1,2,3]);
    
    console.log( document.getElementsByClassName('s1')  );    
    
    let span1 = document.querySelector('span');
    console.log(span1);
    

    let span2 = document.querySelectorAll('span');
    console.log(span2);
    
    let div = document.querySelector('div');

   // 获取 属性值
   let c = div.getAttribute('id');
    console.log(c);

    // 修改属性值
    div.setAttribute('class', 'box9999');
    
    // 删除属性
    div.removeAttribute('class');

    div.style.color = 'red';


</script>

</html>